package com.yuqiao.read.design.templatefun;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Tea extends CaffeineBeverage {
    @Override
    void brew() {
        System.out.println("煮茶");
    }

    @Override
    void addCondiments() {
        System.out.println("添加柠檬");
    }

    @Override
    Boolean hook() {
        String answer = getUserInput();
        if(answer.toLowerCase().startsWith("y")){
            return true;
        }
        return false;
    }

    private String getUserInput() {
        String answer = null;
        System.out.println("你想加檸檬嗎？（y/n）");
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        try {
            answer = in.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if(answer == null){
            return "no";
        }
        return answer;
    }
}
